﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HostTool.Core
{
    /// <summary>
    /// 主机板
    /// </summary>
    class BoardHost:Board
    {

        int ab = 0; //0-A 1-B

        public BoardHost(HostMachine machine,int AB)
            : base(machine)
        {
            this.ab = AB;
            if (ab == 0)
            {
                CPU cpu = new HostControlCPU(this, 0x30, "控制CPU");
                AddCPU(cpu);
                AddCPU(new HostDecodeCPU(this, 0x31, "解码CPU1"));
                AddCPU(new HostDecodeCPU(this, 0x32, "解码CPU2"));
            }
            else
            {
                AddCPU(new HostControlCPU(this, 0x40, "控制CPU"));
                AddCPU(new HostDecodeCPU(this, 0x41, "解码CPU1"));
                AddCPU(new HostDecodeCPU(this, 0x42, "解码CPU2"));
            }
   
        }

        public override string Name
        {
            get
            {
                if (ab == 0)
                {
                    return "主机板A";
                }
                return "主机板B";
            }
        }
    }

    public class HostControlCPU : CPU
    {

        string name = "";
        byte addr = 0;
        public HostControlCPU(IBoard board, byte addr, string name)
            : base(board)
        {
            this.name = name;
            this.addr = addr;
            AddFirmware(new FirmwareType("控制板APP",0x14));
        }


        public override string Name
        {
            get
            {
                return this.name;
            }
        }

        public override byte DstPort
        {
            get
            {
                return addr;
            }
        }

   
    }

    public class HostDecodeCPU : CPU
    {
        string name = "";
        byte addr = 0;
        public HostDecodeCPU(IBoard board, byte addr, string name)
            : base(board)
        {
            this.name = name;
            this.addr = addr;

            AddFirmware(new FirmwareType("解码板APP",0x15));
            AddFirmware(new FirmwareType("DSP BIOS", 0x17));
            AddFirmware(new HostParamFirmType("DSP参数", 0x18));
        }

        public override byte DstPort
        {
            get
            {
              return  this.addr;
            }
        }
        public override string Name
        {
            get
            {
               return this.name;
            }
        }

        public override string Descriptor
        {
            get
            {
                return string.Format("{0}--{1}",this.Board.Name,this.name); 
            }
        }
 
    }

}
